package com.x_memteor.base_master.bean.request;

import android.text.TextUtils;

import com.x_memteor.base_master.base.BaseRequestEntity;
import com.x_memteor.base_master.utils.MD5Utils;

import java.util.HashMap;
import java.util.Map;

/**
 * @author: X_Meteor
 * @description: 类描述
 * @version: V_1.0.0
 * @date: 2018/3/14 0014 上午 11:03
 * @company:
 * @email: lx802315@163.com
 */
public class UpResultBody extends BaseRequestEntity {
    /**
     * macid
     * sign
     * weight				重量
     * fats					体脂
     * water				水分
     * muscle				肌肉
     * skeleton				骨骼
     * calory				卡路里
     * internalOrganLevel	内脏等级
     * subcutaneousFat		皮下脂肪
     * protein				蛋白质
     * perfectWeight		理想体重
     * leanBodyWeight		去脂体重
     */

    private String macid;
    private String id;
    private String token;
    private String sign;
    private String weight;
    private String fats;
    private String water;
    private String muscle;
    private String skeleton;
    private String calory;
    private String internalOrganLevel;
    private String subcutaneousFat;
    private String protein;
    private String perfectWeight;
    private String leanBodyWeight;

    private Map<String, String> requestMap;

    /**
     * macid
     * sign
     * weight				重量
     * fats					体脂
     * water				水分
     * muscle				肌肉
     * skeleton				骨骼
     * calory				卡路里
     * internalOrganLevel	内脏等级
     * subcutaneousFat		皮下脂肪
     * protein				蛋白质
     * perfectWeight		理想体重
     * leanBodyWeight		去脂体重
     */

    public Map<String, String> getRequestMap() {
        if (requestMap == null) {
            requestMap = new HashMap<>();
        }

        requestMap.put("id", id + "");
        requestMap.put("macid", macid + "");
        requestMap.put("sign", sign + "");
        requestMap.put("weight", weight + "");
        requestMap.put("fats", fats + "");
        requestMap.put("water", water + "");
        requestMap.put("muscle", muscle + "");
        requestMap.put("skeleton", skeleton + "");
        requestMap.put("calory", calory + "");
        requestMap.put("internalOrganLevel", internalOrganLevel + "");
        requestMap.put("subcutaneousFat", subcutaneousFat + "");
        requestMap.put("protein", protein + "");
        requestMap.put("perfectWeight", perfectWeight + "");
        requestMap.put("leanBodyWeight", leanBodyWeight + "");

        return requestMap;
    }

    public void setRequestMap(Map<String, String> requestMap) {
        this.requestMap = requestMap;
    }

    public UpResultBody() {
    }

    public void setResult(String id, String macid, String token, String weight, String fats, String water,
                          String muscle, String skeleton, String calory, String internalOrganLevel,
                          String subcutaneousFat, String protein, String perfectWeight, String leanBodyWeight) {

        this.id = id;
        this.macid = macid;
        this.token = token;
        this.weight = weight;
        this.fats = fats;
        this.water = water;
        this.muscle = muscle;
        this.skeleton = skeleton;
        this.calory = calory;
        this.internalOrganLevel = internalOrganLevel;
        this.subcutaneousFat = subcutaneousFat;
        this.protein = protein;
        this.perfectWeight = perfectWeight;
        this.leanBodyWeight = leanBodyWeight;

    }

    public String getToken() {
        return token;
    }

    public void setToken(String token) {
        this.token = token;
    }

    public String getMacid() {
        return macid;
    }

    public void setMacid(String macid) {
        this.macid = macid;
    }

    public void setSign(String sign) {
        this.sign = sign;
    }

    public String getWeight() {
        return weight;
    }

    public void setWeight(String weight) {
        this.weight = weight;
    }

    public String getFats() {
        return fats;
    }

    public void setFats(String fats) {
        this.fats = fats;
    }

    public String getWater() {
        return water;
    }

    public void setWater(String water) {
        this.water = water;
    }

    public String getMuscle() {
        return muscle;
    }

    public void setMuscle(String muscle) {
        this.muscle = muscle;
    }

    public String getSkeleton() {
        return skeleton;
    }

    public void setSkeleton(String skeleton) {
        this.skeleton = skeleton;
    }

    public String getCalory() {
        return calory;
    }

    public void setCalory(String calory) {
        this.calory = calory;
    }

    public String getInternalOrganLevel() {
        return internalOrganLevel;
    }

    public void setInternalOrganLevel(String internalOrganLevel) {
        this.internalOrganLevel = internalOrganLevel;
    }

    public String getSubcutaneousFat() {
        return subcutaneousFat;
    }

    public void setSubcutaneousFat(String subcutaneousFat) {
        this.subcutaneousFat = subcutaneousFat;
    }

    public String getProtein() {
        return protein;
    }

    public void setProtein(String protein) {
        this.protein = protein;
    }

    public String getPerfectWeight() {
        return perfectWeight;
    }

    public void setPerfectWeight(String perfectWeight) {
        this.perfectWeight = perfectWeight;
    }

    public String getLeanBodyWeight() {
        return leanBodyWeight;
    }

    public void setLeanBodyWeight(String leanBodyWeight) {
        this.leanBodyWeight = leanBodyWeight;
    }

    /*
    macid
    token
    weight				重量
    fats				体脂
    water				水分
    muscle				肌肉
    skeleton			骨骼
    calory				卡路里
    internalOrganLevel	内脏等级
    subcutaneousFat		皮下脂肪
    protein				蛋白质
    perfectWeight		理想体重
    leanBodyWeight		去脂体重*/

    @Override
    public String getSign() {
        String sign = "";

        StringBuffer sb = new StringBuffer();

        sb.append("calory=");
        sb.append(calory);
        sb.append("&fats=");
        sb.append(fats);
        sb.append("&id=");
        sb.append(id);
        sb.append("&internalOrganLevel=");
        sb.append(internalOrganLevel);
        sb.append("&leanBodyWeight=");
        sb.append(leanBodyWeight);
        sb.append("&macid=");
        sb.append(macid);
        sb.append("&muscle=");
        sb.append(muscle);
        sb.append("&perfectWeight=");
        sb.append(perfectWeight);
        sb.append("&protein=");
        sb.append(protein);
        sb.append("&skeleton=");
        sb.append(skeleton);
        sb.append("&subcutaneousFat=");
        sb.append(subcutaneousFat);
        sb.append("&token=");
        sb.append(token);
        sb.append("&water=");
        sb.append(water);
        sb.append("&weight=");
        sb.append(weight);

        if (!TextUtils.isEmpty(sb)) {
            sign = MD5Utils.encryptMD5(sb.toString());
        }
        this.sign = sign;
        return sign;
    }

    @Override
    public String getCiphertext() {
        return null;
    }
}
